package edu.sctu.jsoup.service;
import edu.sctu.jsoup.entity.StudentEntity;
import edu.sctu.jsoup.repo.StudentRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentRepo studentRepo;


    public void  run(){
        List<StudentEntity> studentEntities=studentRepo.findByName("chen");
        for(StudentEntity entity : studentEntities){
            System.out.println(entity.getId());
            System.out.println(entity.getName());
            System.out.println(entity.getAge());
        }

        StudentEntity chen = new StudentEntity();
        chen.setName("陈");
        chen.setAge(30);

        studentRepo.save(chen);
    }

}
